Binary Search Visualization
A[0] |
A[1] |
A[2] |
A[3] |
A[4] |
A[5] |
A[6] |
A[7] |
A[8] |
A[9] |
A[10] |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
|
|
|
|
|
|
|
|
|
|
|
Pseudo Code
- procedure binary_search (list, value)
- while low <=high< /li>
- mid = (low + high) / 2
- if (A[mid] < value)
-
low = mid + 1
- else if (A[mid] > value)
- high = mid - 1
- else
- retrun mid
- end while
- end porcedure